package test.service;

import org.zw.android.framework.http.HttpUIHandler;

import android.content.Context;
import android.os.Message;
import android.widget.Toast;

public class AppHanlder extends HttpUIHandler {

	static final String TAG = "BaseHandler";

	protected Context mContext;

	public AppHanlder(Context context) {
		super(context);
		mContext = context;
	}

	public void showText(String text){
		if(mContext != null){
			Toast.makeText(mContext, text, Toast.LENGTH_SHORT).show() ;
		}
	}
	
	@Override
	public final void notifyHttpUI(Message msg) {
		
		switch(msg.what){
		case MSG_STATUS_START :
			showText("开始任务");
			break ;
		case MSG_STATUS_FINISH :
			notify(msg);
			break ;
		}
	}
	
	public void notify(Message msg){
		
	}

	@Override
	public void notifyError(Message msg) {
		showText(msg.obj != null ? msg.obj.toString() : "异步任务出异常了");
	}

	@Override
	public void notifyCancel(Message msg) {
		showText("任务取消");
	}

	@Override
	protected void notifyNormalFilterFailed(Message msg) {
		showText(msg.obj != null ? msg.obj.toString() : "API 失败");
	}

	@Override
	protected void notifyParserFilterFailed(Message msg) {
		
	}
}
